﻿using System.Collections.Generic;
using System.Web.Services;
using BLL;
using BLL.RF.TestRecord;
using Model.RF.TestRecord;

/// <summary>
///Test_Record_OIP3_DataUploadAndProcessControl_Service 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。 
// [System.Web.Script.Services.ScriptService]
public class Test_Record_OIP3_DataUploadAndProcessControl_Service : System.Web.Services.WebService
{
    private ProductType p;
    private ProductType_Flow pf;
    private Test_Record tr;
    private TestItem_Record tir;
    private ATEUser user;

    public Test_Record_OIP3_DataUploadAndProcessControl_Service()
    {
        p = new ProductType();
        pf = new ProductType_Flow();
        tr = new Test_Record();
        tir = new TestItem_Record();
        user = new ATEUser();
        //如果使用设计的组件，请取消注释以下行 
        //InitializeComponent(); 
    }

    [WebMethod(Description = "判断产品类型S代码是否合法，在数据上传之前调用")]
    public bool IsValidProductTypeID(string productTypeID)
    {
        return p.ProductType_Exist(productTypeID);
    }

    [WebMethod(Description = "OIP3测试前时，判断之前工序是否有合格记录")]
    public bool ProductType_Flow_HasValidSevenStep_ForOIP3(string productSN, string productTypeID)
    {
        return pf.ProductType_Flow_HasValidSevenStep(productSN, productTypeID, "OIP3Step");
    }

    [WebMethod(Description = "上传OIP3测试数据")]
    public bool OIP3Data_Upload(Test_RecordInfo tri, List<TestItem_RecordInfo> list)
    {
        try
        {
            tri.ProductSN = CommHelper.GetProductSN(tri.ProductSN);
            int id = tr.Test_Record_Insert_OIP3(tri);
            foreach (TestItem_RecordInfo tiri in list)
            {
                tiri.ID = id;
                tiri.ProductSN = tri.ProductSN;
                tir.Insert(tiri);
            }
            return true;
        }
        catch
        {
            return false;
        }
    }


    #region 20180403日，增加测试录入工号管控

    [WebMethod(Description = "测试前校验录入工号，是否系统已经配置为“测试”的工号")]
    public bool IsValidUserID_forTest(string userID)
    {
        return user.ATEUser_IsValidForTest(userID);
    }
    #endregion
}

